import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/views/layout/Layout'

/** note: Submenu only appear when children.length>=1
 *  detail see  https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 **/

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirect in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    roles: ['admin','editor']     will control the page roles (you can set multiple roles)
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
    noCache: true                if true ,the page will no be cached(default is false)
  }
**/
export const constantRouterMap = [
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path*',
        component: () => import('@/views/redirect/index')
      }
    ]
  },
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    path: '/auth-redirect',
    component: () => import('@/views/login/authredirect'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/errorPage/404'),
    hidden: true
  },
  {
    path: '/401',
    component: () => import('@/views/errorPage/401'),
    hidden: true
  },
  {
    path: '',
    component: Layout,
    redirect: 'dashboard',
    children: [
      {
        path: 'dashboard',
        component: () => import('@/views/dashboard/index'),
        name: 'Dashboard',
        meta: { title: '我的工作台', icon: 'dashboard', noCache: true }
      }
    ]
  }
]

export default new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})

export const asyncRouterMap = [
/*
  {
    path: '/charts',
    component: Layout,
    redirect: 'noredirect',
    name: 'Charts',
    meta: {
      title: '图表',
      icon: 'chart'
    },
    children: [
      {
        path: 'mixchart',
        component: () => import('@/views/charts/mixChart'),
        name: 'MixChart',
        meta: { title: '折线与柱状图', noCache: true }
      },
      {
        path: 'kongbai',
        component: () => import('@/views/charts/kongBai'),
        name: 'Kongbai',
        meta: { title: '空白页面' }
      }
    ]
  },

  {
    path: '/table',
    component: Layout,
    redirect: '/table/complex-table',
    name: 'Table',
    meta: {
      title: 'Table',
      icon: 'table'
    },
    children: [
      {
        path: 'inline-edit-table',
        component: () => import('@/views/table/inlineEditTable'),
        name: 'InlineEditTable',
        meta: { title: 'inlineEditTable' }
      },
      {
        path: 'complex-table',
        component: () => import('@/views/table/complexTable'),
        name: 'ComplexTable',
        meta: { title: 'complexTable' }
      }
    ]
  },

  {
    path: '/tab',
    component: Layout,
    name: 'Tab',
    redirect: '/tab/tab1',
    meta: {
      title: 'tab',
      icon: 'tab'
    },
    children: [
      {
        path: 'tab1',
        component: () => import('@/views/tab/tab1'),
        name: 'Tab1',
        meta: { title: 'tab1' }
      },
      {
        path: 'tab2',
        component: () => import('@/views/tab/tab2'),
        name: 'Tab2',
        meta: { title: 'tab2' }
      }
    ]
  },
*/

  {
    path: '/tab101',
    component: Layout,
    name: 'tab101',
    redirect: '/tab/tab101',
    meta: {
      title: '操作功能(商户端)',
      icon: 'tab'
    },
    children: [
      {
        path: 'page101',
        component: () => import('@/views/tab/tab101'),
        name: 'page101',
        meta: { title: 'A1.我的常用首页' }
      },
      {
        path: 'page102',
        component: () => import('@/views/table/complexTable102'),
        name: 'page102',
        meta: { title: 'B1.快速下单操作' }
      },
      {
        path: 'page103',
        component: () => import('@/views/table/complexTable103'),
        name: 'page103',
        meta: { title: 'B2.补货下单操作' }
      },
      {
        path: 'page104',
        component: () => import('@/views/table/complexTable104'),
        name: 'page104',
        meta: { title: 'B3.订单信息复核' }
      },
      {
        path: 'page105',
        component: () => import('@/views/table/complexTable105'),
        name: 'page105',
        meta: { title: 'B4.等待付款订单' }
      },
      {
        path: 'page106',
        component: () => import('@/views/table/complexTable106'),
        name: 'page106',
        meta: { title: 'B5.等待收货订单' }
      },
      {
        path: 'page107',
        component: () => import('@/views/table/complexTable107'),
        name: 'page107',
        meta: { title: 'C1.商品信息查询' }
      },
      {
        path: 'page108',
        component: () => import('@/views/table/complexTable603'),
        name: 'page108',
        meta: { title: 'C2.订单信息查询' }
      },
      {
        path: 'page109',
        component: () => import('@/views/charts/mixChart605'),
        name: 'page109',
        meta: { title: 'C3.订货数据分析' }
      }
    ]
  },

  {
    path: '/tab201',
    component: Layout,
    name: 'tab201',
    redirect: '/tab/tab201',
    meta: {
      title: '基础配置(品牌商端)',
      icon: 'tab'
    },
    children: [
      {
        path: 'page201',
        component: () => import('@/views/table/complexTable201'),
        name: 'page201',
        meta: { title: 'A1.新商户准入开通' }
      },
      {
        path: 'page202',
        component: () => import('@/views/table/complexTable202'),
        name: 'page202',
        meta: { title: 'A2.新商户权限配置' }
      },
      {
        path: 'page203',
        component: () => import('@/views/table/complexTable203'),
        name: 'page203',
        meta: { title: 'A3.控制规则自定义' }
      },
      {
        path: 'page204',
        component: () => import('@/views/table/complexTable204'),
        name: 'page204',
        meta: { title: 'B1.新商品信息发布' }
      },
      {
        path: 'page205',
        component: () => import('@/views/table/complexTable205'),
        name: 'page205',
        meta: { title: 'B2.新商品发布审核' }
      },
      {
        path: 'page206',
        component: () => import('@/views/table/complexTable206'),
        name: 'page206',
        meta: { title: 'C1.建议补单款发布' }
      },
      {
        path: 'page207',
        component: () => import('@/views/table/complexTable207'),
        name: 'page207',
        meta: { title: 'C2.建议补单款审核' }
      },
      {
        path: 'page208',
        component: () => import('@/views/table/complexTable208'),
        name: 'page208',
        meta: { title: 'D1.商户等级认定' }
      },
      {
        path: 'page209',
        component: () => import('@/views/table/complexTable209'),
        name: 'page209',
        meta: { title: 'D2.等级认定审核' }
      }
    ]
  },

  {
    path: '/tab301',
    component: Layout,
    name: 'tab301',
    redirect: '/tab/tab301',
    meta: {
      title: '订单管理(品牌商端)',
      icon: 'tab'
    },
    children: [
      {
        path: 'page301',
        component: () => import('@/views/table/complexTable301'),
        name: 'page301',
        meta: { title: 'A1.待集中审核订单' }
      },
      {
        path: 'page302',
        component: () => import('@/views/table/complexTable302'),
        name: 'page302',
        meta: { title: 'A2.已集中审核订单' }
      },
      {
        path: 'page303',
        component: () => import('@/views/table/complexTable603'),
        name: 'page303',
        meta: { title: 'B1.订单信息查询' }
      },
      {
        path: 'page304',
        component: () => import('@/views/charts/mixChart605'),
        name: 'page304',
        meta: { title: 'B2.订单数据分析' }
      }
    ]
  },

  {
    path: '/tab401',
    component: Layout,
    name: 'tab401',
    redirect: '/tab/tab401',
    meta: {
      title: '物流管理(品牌商端)',
      icon: 'tab'
    },
    children: [
      {
        path: 'page401',
        component: () => import('@/views/table/complexTable401'),
        name: 'page401',
        meta: { title: 'A1.待发货订单' }
      },
      {
        path: 'page402',
        component: () => import('@/views/table/complexTable402'),
        name: 'page402',
        meta: { title: 'A2.已发货订单' }
      },
      {
        path: 'page403',
        component: () => import('@/views/table/complexTable403'),
        name: 'page403',
        meta: { title: 'A3.已收货订单' }
      },
      {
        path: 'page404',
        component: () => import('@/views/table/complexTable603'),
        name: 'page404',
        meta: { title: 'B1.订单物流查询' }
      },
      {
        path: 'page406',
        component: () => import('@/views/table/complexTable406'),
        name: 'page406',
        meta: { title: 'C1.收货异常订单' }
      }
    ]
  },

  {
    path: '/tab501',
    component: Layout,
    name: 'tab501',
    redirect: '/tab/tab501',
    meta: {
      title: '货款管理(品牌商端)',
      icon: 'tab'
    },
    children: [
      {
        path: 'page501',
        component: () => import('@/views/table/complexTable501'),
        name: 'page501',
        meta: { title: 'A1.待核对定金订单' }
      },
      {
        path: 'page502',
        component: () => import('@/views/table/complexTable502'),
        name: 'page502',
        meta: { title: 'A2.已核对定金订单' }
      },
      {
        path: 'page503',
        component: () => import('@/views/table/complexTable503'),
        name: 'page503',
        meta: { title: 'B1.待核对余款订单' }
      },
      {
        path: 'page504',
        component: () => import('@/views/table/complexTable504'),
        name: 'page504',
        meta: { title: 'B2.已核对余款订单' }
      },
      {
        path: 'page506',
        component: () => import('@/views/table/complexTable604'),
        name: 'page506',
        meta: { title: 'C1.订单货款查询' }
      },
      {
        path: 'page505',
        component: () => import('@/views/tab/tab505'),
        name: 'page505',
        meta: { title: 'C2.订单货款分析' }
      }
    ]
  },

  {
    path: '/tab701',
    component: Layout,
    name: 'tab701',
    redirect: '/tab/tab701',
    meta: {
      title: '库存管理(品牌商端)',
      icon: 'tab'
    },
    children: [
      {
        path: 'page701',
        component: () => import('@/views/table/complexTable701'),
        name: 'page701',
        meta: { title: 'A1.待入库商品' }
      },
      {
        path: 'page702',
        component: () => import('@/views/table/complexTable702'),
        name: 'page702',
        meta: { title: 'A2.已入库商品' }
      },
      {
        path: 'page703',
        component: () => import('@/views/table/complexTable703'),
        name: 'page703',
        meta: { title: 'B1.待出库商品' }
      },
      {
        path: 'page704',
        component: () => import('@/views/table/complexTable704'),
        name: 'page704',
        meta: { title: 'B2.已出库商品' }
      },
      {
        path: 'page705',
        component: () => import('@/views/table/complexTable705'),
        name: 'page705',
        meta: { title: 'C1.库存异常调整' }
      },
      {
        path: 'page706',
        component: () => import('@/views/table/complexTable706'),
        name: 'page706',
        meta: { title: 'C2.异常调整审核' }
      },
      {
        path: 'page707',
        component: () => import('@/views/table/complexTable707'),
        name: 'page707',
        meta: { title: 'D1.最新库存查询' }
      },
      {
        path: 'page708',
        component: () => import('@/views/table/complexTable708'),
        name: 'page708',
        meta: { title: 'D2.库存变动查询' }
      }
    ]
  },

  {
    path: '/tab601',
    component: Layout,
    name: 'tab601',
    redirect: '/tab/tab601',
    meta: {
      title: '统计分析(品牌商端)',
      icon: 'tab'
    },
    children: [
      {
        path: 'page601',
        component: () => import('@/views/table/complexTable601'),
        name: 'page601',
        meta: { title: 'A1.商户信息查询' }
      },
      {
        path: 'page602',
        component: () => import('@/views/table/complexTable602'),
        name: 'page602',
        meta: { title: 'A2.商品信息查询' }
      },
      {
        path: 'page603',
        component: () => import('@/views/table/complexTable603'),
        name: 'page603',
        meta: { title: 'A3.订单信息查询' }
      },
      {
        path: 'page604',
        component: () => import('@/views/table/complexTable604'),
        name: 'page604',
        meta: { title: 'A4.支付款项查询' }
      },
      {
        path: 'page605',
        component: () => import('@/views/tab/tab605'),
        name: 'page605',
        meta: { title: 'B1.自定义高级查询' }
      },
      {
        path: 'page606',
        component: () => import('@/views/dashboard/index607'),
        name: 'page606',
        meta: { title: 'B2.自定义数据分析' }
      },
      {
        path: 'page607',
        component: () => import('@/views/charts/mixChart605'),
        name: 'page607',
        meta: { title: 'B3.自定义排名分析' }
      }
    ]
  },

  {
    path: '/tab901',
    component: Layout,
    name: 'tab901',
    redirect: '/tab/tab901',
    meta: {
      title: '系统配置(品牌商端)',
      icon: 'tab'
    },
    children: [
      {
        path: 'page901',
        component: () => import('@/views/table/complexTable901'),
        name: 'page901',
        meta: { title: 'S1.机构部门定义' }
      },
      {
        path: 'page902',
        component: () => import('@/views/table/complexTable902'),
        name: 'page902',
        meta: { title: 'S2.角色信息定义' }
      },
      {
        path: 'page903',
        component: () => import('@/views/table/complexTable903'),
        name: 'page903',
        meta: { title: 'S3.用户信息定义' }
      },
      {
        path: 'page904',
        component: () => import('@/views/table/complexTable904'),
        name: 'page904',
        meta: { title: 'S4.字典代码定义' }
      },
      {
        path: 'page905',
        component: () => import('@/views/table/complexTable905'),
        name: 'page905',
        meta: { title: 'S5.菜单权限定义' }
      },
      {
        path: 'page906',
        component: () => import('@/views/table/complexTable906'),
        name: 'page906',
        meta: { title: 'S6.控制参数定义' }
      }
    ]
  },

  { path: '*', redirect: '/404', hidden: true }
]
